   package healthyCal;

   import java.util.Scanner;

   public class healthyCal {
       // 定义性别常量
       private static final int MALE = 1;
       private static final int FEMALE = 2;

       public static void main(String[] args) {
           Scanner scanner = new Scanner(System.in);

           // 获取用户输入
           System.out.print("请输入您的年龄: ");
           int age = scanner.nextInt();

           System.out.print("请输入您的性别 (1 - 男性, 2 - 女性): ");
           int gender = scanner.nextInt();

           System.out.print("请输入您的体重 (公斤): ");
           double weight = scanner.nextDouble();

           System.out.print("请输入您的身高 (厘米): ");
           double height = scanner.nextDouble();

           // 计算 BMI
           double bmi = calculateBMI(weight, height);
           System.out.printf("您的 BMI 是: %.2f\n", bmi);

           // 计算 BMR
           double bmr = calculateBMR(age, gender, weight, height);
           System.out.printf("您的基础代谢率 (BMR) 是: %.2f 卡路里/天\n", bmr); // 修复此处

           scanner.close();
       }

       // 计算 BMI
       public static double calculateBMI(double weight, double height) {
           return weight / Math.pow(height / 100, 2);
       }

       // 计算 BMR
       public static double calculateBMR(int age, int gender, double weight, double height) {
           if (gender == MALE) {
               return 88.362 + (13.397 * weight) + (4.799 * height) - (5.677 * age);
           } else if (gender == FEMALE) {
               return 447.593 + (9.247 * weight) + (3.098 * height) - (4.330 * age);
           } else {
               throw new IllegalArgumentException("无效的性别输入");
           }
       }
   }
